package com.wanxi.service.impl;

import com.wanxi.dao.CompanyDao;
import com.wanxi.model.CompanyModel;
import com.wanxi.model.ResultModel;
import com.wanxi.service.CompanyService;
import com.wanxi.util.SnowflakeIdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 杨金乾
 */
@Service
public class CompanyServiceImpl implements CompanyService {
    @Autowired
    CompanyDao companyDao;
    @Override
    public ResultModel enable(CompanyModel companyModel) {
        return null;
    }

    @Override
    public ResultModel add(CompanyModel companyModel) {
        SnowflakeIdWorker snowflakeIdWorker=new SnowflakeIdWorker(WorkId.WORK_ID);
        companyModel.setId(snowflakeIdWorker.nextId());
        return ResultModel.getResult(companyDao.add(companyModel));
    }

    @Override
    public ResultModel update(CompanyModel companyModel) {
        return ResultModel.getResult(companyDao.update(companyModel));
    }

    @Override
    public ResultModel delete(CompanyModel companyModel) {
        return ResultModel.getResult(companyDao.delete(companyModel));
    }

    @Override
    public ResultModel findById(CompanyModel companyModel) {
        return ResultModel.getResult(companyDao.findById(companyModel));
    }

    @Override
    public ResultModel findAll(CompanyModel companyModel) {
        companyModel.setLimit(10);
        companyModel.setPage((companyModel.getPage()-1)*10);
        return ResultModel.getResult(companyDao.findAll(companyModel), companyDao.count(companyModel));

    }

    @Override
    public ResultModel count(CompanyModel companyModel) {
        return ResultModel.getResult(companyDao.count(companyModel));
    }

    @Override
    public ResultModel isShow(CompanyModel companyModel) {
        return ResultModel.getResult(companyDao.isShow(companyModel));
    }

    @Override
    public ResultModel isRecommend(CompanyModel companyModel) {
        return null;
    }

    @Override
    public ResultModel whereShow(CompanyModel companyModel) {
        return null;
    }
}
